#ifndef OXFORDWORDUPDATER_H
#define OXFORDWORDUPDATER_H

#include <QObject>
#include <QRunnable>
#include "database-manager.h"
#include "oxford-loader.h"
#include "oxford-parser.h"

namespace Oxford
{

class WordUpdater : public QObject, public QRunnable
{
    Q_OBJECT
private:
    Core::DatabaseManager* databaseManager;
    Parser oxfordParser;
    Loader oxfordLoader;

    QStringList _words;
    bool _deepMode;

    bool _needToLoad(const QString& word);
    bool _goodWord(const Word& wordData);
public:
    explicit WordUpdater();
    ~WordUpdater();

    void setWordsList(const QStringList& words);
    void setDeepMode(bool deepMode);
    void run();

signals:
    void updateStarted();
    void updateFinished();

    void logMessage(const QString& message);
    void logError(const QString& error);
};

}

#endif // OXFORDWORDUPDATER_H
